/*!
 * Copyright 2019 WeBank
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

@import "normalize";

$title-color : #464c5b;
$text-color : #657180;
$sub-text-color : #999;
$dark-color : #333;

// Border color
$border-color-base : #d7dde4; // outside
$border-color-split : #e3e8ee; // inside


// Background color
$background-color-base : #f7f7f7;
$hover-color : #f3f3f3;
$tooltip-color : #fff;

// Shadow
$shadow-color : rgba(0, 0, 0, .2);
$shadow-1-up : 0 -1px 6px $shadow-color;
$shadow-1-down : 0 1px 6px $shadow-color;
$shadow-1-left : -1px 0 6px $shadow-color;
$shadow-1-right : 1px 0 6px $shadow-color;
$shadow-2 : 0 2px 8px $shadow-color;
$box-shadow-base : $shadow-1-down;

$mask-color: rgba(55, 55, 55, .6);

.designer {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    user-select: none;
    outline: none;
    font-size: 12px;
    color: $text-color;
    background: #fff;

    * {
        box-sizing: border-box;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }

    *:before,
    *:after {
        box-sizing: border-box;
    }

    input,
    textarea,
    .designer-button {
        height: 26px;
        line-height: 26px;
        padding: 0 8px;
        border: 1px solid $border-color-base;
        outline: 0;
        font-size: 12px;
        border-radius: 2px;
        color: $text-color;
        background-color: $tooltip-color;
    }

    .designer-button {
        padding: 0 12px;
    }

    .designer-toolbar {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 36px;
        padding-left: 10px;
        background: $background-color-base;
        color: #000;
        border: 1px solid $border-color-base;

        .icon {
            display: inline-block;
            vertical-align: text-top;
            width: 18px;
            height: 18px;
            color: $dark-color;
            text-align: center;
        }

        .text {
            vertical-align: text-top;
        }

        .button {
            float: left;
            margin: 6px 5px 6px 0;
            padding: 0;
            height: 18px;
            // width: 54px;
            text-align: left;
            border: 1px solid transparent;
            border-radius: 2px;
            position: relative;
            cursor: pointer;
            svg {
                margin-right: 5px;
                color: #666;
            }
            span {
                vertical-align: middle;
                color: #666;
            }
        }

        .long-button {
            min-width: 60px;
        }

        .devider {
            float: left;
            border-left: 1px solid $border-color-split;
            height: 18px;
            margin: 8px 5px;
        }
    }

    &.show-toolbar {

        .designer-shape,
        .designer-viewport,
        .right-draw,
        .designer-control {
            top: 36px;
        }
    }

    .designer-shape {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 200px;
        overflow-x: hidden;
        overflow-y: auto;
        background: $background-color-base;
        border-right: 1px solid $border-color-base;

        .shape-search {
            display: block;
            width: 80%;
            margin: 10px auto;
        }

        .shape-container {
            margin-top: 1px;
            border-bottom: 1px solid $border-color-split;

            &.top {
                border-top: 1px solid $border-color-split;
            }

            .icon {
                height: 14px;
                width: 14px;
            }

            .shape-title {
                position: relative;
                margin: 0px;
                height: 30px;
                line-height: 30px;
                padding-left: 20px;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
                cursor: pointer;
                color: $title-color;
                font-weight: 400;
            }

            .shape-content {
                padding-bottom: 10px;
                padding-left: 10px;
            }
        }

        .shape-box {
            display: inline-block;
            margin: 5px;
            width: 60px;
            text-align: center;
            cursor: pointer;
        }
        .shape-title-txt {
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .shape-box-img {
            display: inline-block;
            width: 36px;
            height: 100%;
            user-select: none;
            pointer-events: none;
        }

        .shape-box-draging {
            position: absolute;
            text-align: center;
            border-radius: 4px;
            opacity: 0.5;
            cursor: all-scroll;
        }
    }

    .designer-viewport {
        position: absolute;
        left: 200px;
        top: 0;
        right: 0;
        bottom: 0;
        overflow: auto;
    }

    .snap-line {
        position: absolute;
        z-index: 4;
        background: #6eb1eb;
    }

    .node-box {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 2;
        background: #fff;
        cursor: move;

        &:hover {
            .node-anchor {
                display: block;
            }
        }

        .node-anchor {
            display: none;
            position: absolute;
            z-index: 1;
            border-color: #ff9900;
            border-style: solid;
            border-width: 1px;
            background: white;
            cursor: crosshair;
        }

        .node-box-bg {
            user-select: none;
            pointer-events: none;
        }

        .node-box-content {
            position: absolute;
            left: 30%;
            top: 0;
            bottom: 0;
            right: 16%;
            z-index: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }

    .linker-box {
        position: absolute;
        z-index: 1;
        display: none;
    }

    .drag-linker-box {
        cursor: crosshair;
    }

    .right-draw {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 400px;
        border-left: 1px solid $border-color-base;
        border-right: 1px solid $border-color-base;
        box-shadow: -6px 0 6px -6px $shadow-color;
        overflow: auto;
        z-index: 1100;
        color: $text-color;
        background: #fff;

        .icon {
            width: 14px;
            height: 14px;
            cursor: pointer;
        }

        .right-draw-title {
            padding: 0 20px;
            height: 36px;
            line-height: 36px;
            color: $title-color;
            border-bottom: 1px solid $border-color-split;
            font-size: 12px;
            font-weight: 500;

            .icon {
                width: 16px;
                height: 16px;
                float: right;
                color: #464c5b;
                margin-top: 6px;
            }
        }

        .right-draw-content {
            padding: 0 20px;
        }

        .row {
            margin: 16px 0;
            font-size: 0;

            .row-name {
                padding-right: 20px;
                display: inline-block;
                vertical-align: middle;
                width: 100px;
                text-align: right;
                font-size: 12px;
            }

            .half {
                display: inline-block;
                width: 50%;
                vertical-align: middle;
                font-size: 12px;
                text-align: center;
            }

            .row-input {
                vertical-align: middle;
                width: 200px;
            }

            .row-button {
                cursor: pointer;

                &:hover {
                    background: $hover-color;
                }
            }

            textarea {
                min-height: 52px;
            }
        }
    }

    .baseinfo {
        .row-button {
            margin-left: 100px;
        }
    }

    .paraminfo {
        .row-button {
            margin-left: 155px;
        }
    }

    .designer-control {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 14px;
        width: 36px;
        z-index: 1000;

        .designer-control-header {
            background: #5c5c5c;
            background-image: linear-gradient(top, #5c5c5c, #3e3e3e);
            height: 8px;
            border-left: 1px solid #5c5c5c;
            border-right: 1px solid #5c5c5c;
            border-top: 1px solid #646464;
            border-bottom: 1px solid #000;
        }

        .designer-control-buttons {
            background-color: #fff;
            padding: 10px 0px 10px;
            border-left: 1px solid #d7dde4;
            border-right: 1px solid #d7dde4;
            border-bottom: 1px solid #d7dde4;
            overflow: hidden;
        }

        .designer-control-button {
            position: relative;
            margin: 5px 5px 5px 5px;
            height: 24px;
            line-height: 24px;
            text-align: center;
            font-size: 18px;
            cursor: pointer;
        }

        .designer-control-dialog {
            position: absolute;
            top: 50px;
            right: 40px;
            width: 220px;
            height: 120px;
            background: #fff;
            border: 2px solid rgba(0, 0, 0, 0.5);
            box-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);

            .line-type {
                width: 100%;
                height: 40px;
                display: flex;
                justify-content: center;

                input,
                label {
                    margin: 0 3px;
                    align-self: center;
                    cursor: pointer;
                }
            }

            .node-width-container {
                width: 100%;
                height: 40px;
                text-align: center;
            }

            .operations {
                width: 100%;
                height: 40px;
                text-align: center;

                .format,
                .cancel {
                    margin-left: 5px;
                    display: inline-block;
                    width: 50px;
                    height: 24px;
                    line-height: 24px;
                    border: 1px solid #d7dde4;
                    cursor: pointer;

                    &:hover {
                        border: 1px solid black;
                    }
                }
            }
        }

        .designer-control-dialog.reset {
            top: 120px;
            height: 90px;

            .hint {
                margin-top: 5px;
                width: 100%;
                height: 40px;
                line-height: 40px;
                text-align: center;
            }
        }
    }

    .box-select-layer {
        position: absolute;
        left: 0;
        top: 0;
        border: 1px solid #3399ff;
        background-color: rgba(51, 153, 255, 0.28);
        z-index: 999;
        display: none;
    }
    .node-selected {
        box-shadow: 0 0 8px #3399ff;
    }
}

.designer-menu {
    position: absolute;
    overflow: auto;
    padding: 6px 0;
    background-color: #fff;
    box-sizing: border-box;
    border-radius: 4px;
    box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.25);
    z-index: 900;

    .designer-menu-ul {
        min-width: 100px;

        .designer-menu-li {
            position: relative;
            padding: 0 10px;
            margin: 0;
            line-height: 25px;
            height: 25px;
            color: $text-color;
            font-size: 12px;
            text-align: left;
            clear: both;
            white-space: nowrap;
            list-style: none;
            cursor: pointer;
            transition: background 0.2s ease-in-out;

            &:hover {
                background: $hover-color;
            }
        }
    }

    .designer-menu-li-icon {
        display: inline-block;
        vertical-align: middle;
        height: 16px;
        width: 16px;
        margin-top: -1px;
        color: $text-color;
    }
    .menu-img {
        margin-left: 5px;
    }
    .designer-menu-li-text {
        margin-left: 10px;
        vertical-align: middle;
    }
}
.executor-pending {
    position: absolute;
    background: #fff;
    border: 2px solid #666;
    right: -30px;
    top: -37px;
    border-radius: 4px;
    padding: 3px;
   }
   .executor-pending:after, .executor-pending:before {
    top: 100%;
    left: 50%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
   }

   .executor-pending:after {
    border-top-color: #fff;
    border-width: 7px;
    margin-left: -23px;
   }
   .executor-pending:before {
    border-top-color: #666;
    border-width: 10px;
    margin-left: -26px;
   }
   .executor-icon {
    position: absolute;
    right: 10px;
    top: 10px;
   }
   .executor-success {
    color: rgba(78, 225, 78, 0.7);
   }
   .executor-faile {
       color: rgb(237, 64, 20);
   }
   .executor-skip {
    color: rgb(255, 153, 0);
   }
   .executor-loading {
    animation: loading 2s linear 0s infinite ;
    color: rgba(83, 219, 233, 0.7);
   }
   @keyframes loading {
       from {
        transform: rotateZ(0deg);
       } to {
        transform: rotateZ(360deg);
       }
   }
